﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using EuphoricNation.Util;
using EuphoricNation.Page;

public partial class templates_Accounts_Login : EuphoricNationPage
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (Authentication.UserLoggedIn)
            Useful.RedirectTemporary("/");

        //Authentication.UnlockUser("shanesimpkins@gmail.com");
        //Authentication.UpdateUserPassword("shanesimpkins@gmail.com", "shane123");
    }

    protected void LoginBtn_Click(object sender, EventArgs e)
    {
        if (Authentication.Login(Username.Text, Password.Text))
        {
            Useful.RedirectTemporary("/");

            //
            // TODO: Change this to get the ContentBase<User> from the database and get their login url!
            //
            //       Perhaps we could look at adding the same functionality to the logout button; Which we will need to make and add to the navigation bar.
            //       It would be best to get the user entity (which we get the logout url from) in the master file in the logoutbtn_click event,
            //          then add a method to the authentication class that is 'Logout(string targetURL);'!
            //
        }
        else
            Msg.Text = "<p><strong>Sorry, but the credentials you entered could not be found. Please try again.</strong></p>";
    }

    protected void CancelBtn_Click(object sender, EventArgs e)
    {
        Useful.RedirectTemporary("/");
    }
}
